import socketio

username = input("Your username pls: ")

sio = socketio.Client()


@sio.on('tab_info')
def recv_tab(obj):
    print("Received table : {}".format(obj))
    if i % 2 != 0:
        sio.emit('cancel', {"user": username})

@sio.on('your_sid')
def recv_tab(obj):
    print("Received SID : {}".format(obj))

@sio.on('Notification')
def recv_bill(s):
    print(s)

i = 0

try:
    sio.connect("http://localhost:1200")
    while True:
        if i % 3 == 0:
            sio.emit('get_tab',  {"user": username, "table_name" : "null_table"})
        else:
            sio.emit('my_sid', {"user": username})
        i += 1
        sio.sleep(3)

except:
    sio.disconnect()